package com.peanut.baby.mvp.mydata;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.peanut.baby.R;
import com.peanut.baby.model.Record;
import com.peanut.baby.util.TimeUtil;
import com.peanut.devlibrary.util.StringUtil;
import com.peanut.devlibrary.widget.pullrecycle.BaseRecyclerAdapter;
import com.peanut.devlibrary.widget.pullrecycle.BaseViewHolder;

import java.util.List;

/**
 * Created by anonymouslystudio on 2017/8/28.
 */

public class RecordRecyclerAdapter extends BaseRecyclerAdapter<Record>{
    public RecordRecyclerAdapter(Context context, List<Record> data) {
        super(context, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, Record item) {
        ImageView imgFlag = holder.getView(R.id.record_image_flag);
        TextView  type = holder.getView(R.id.record_category);
        TextView  time = holder.getView(R.id.record_time);
        TextView  desc = holder.getView(R.id.record_desc);

        if(StringUtil.isNullOrEmpty(item.imgUrl)){
            imgFlag.setVisibility(View.GONE);
        }else{
            imgFlag.setVisibility(View.VISIBLE);
        }

        type.setText(item.type);
        time.setText(TimeUtil.getDisplayTimeMillis(item.createTime));
        desc.setText(item.desc);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.layout_item_record;
    }
}
